package com.czl.module_storehouse.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.czl.module_storehouse.R;
import com.czl.module_storehouse.bean.StoreProjectBean;

import java.util.List;

/**
 * @author xubin
 */
public class SelectProjectAdapter extends BaseQuickAdapter<StoreProjectBean, BaseViewHolder> {

    public SelectProjectAdapter(int layoutResId, @Nullable List<StoreProjectBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, StoreProjectBean item) {
        helper.setText(R.id.tv_name, item.getMiniProjectName())
                .setText(R.id.tv_company, item.getParentCompanyShortName())
                .setText(R.id.tv_date, item.getCompleteTime())
                .setText(R.id.tv_project, item.getProjectName());
        helper.getView(R.id.iv_right).setOnClickListener(v -> {
            if (getOnItemChildClickListener() != null) {
                getOnItemChildClickListener().onItemChildClick(SelectProjectAdapter.this, v, helper.getLayoutPosition());
            }
        });
        helper.getView(R.id.text_look).setOnClickListener(v -> {
            if (getOnItemChildClickListener() != null) {
                getOnItemChildClickListener().onItemChildClick(SelectProjectAdapter.this, v, helper.getLayoutPosition());
            }
        });
        helper.getView(R.id.cl_root).setOnClickListener(v -> {
            if (getOnItemChildClickListener() != null) {
                getOnItemChildClickListener().onItemChildClick(SelectProjectAdapter.this, v, helper.getLayoutPosition());
            }
        });
    }
}
